var server = "http://ydev.netii.net/api.php";

var ays = true;

function myCall(URL) {
	var request = $.ajax({
		url : URL,
		type : "GET",
		async : ays
	});
	return request;
	/* request.done(function (result) {
	 // alert(result);
	 return request;
	 });
	 request.fail(function (jqXHR, textStatus) {
	 alert("Request failed: " + textStatus);
	 });*/
}

function createURLParams(params) {
	var request = '';
	for (var i in params) {
		request += i + "=" + params[i] + "&";

	}
	return request;
}

function authenticateUser() {
	var authen = false;
	var params = new Array();
	params['action'] = "authenticate";
	var param = createURLParams(params);
	var URL = server + "?" + param;
	//return true;
	ays = false;
	
	var request = myCall(URL);
	request.done(function(result) {
		var obj = jQuery.parseJSON(result);
		if (obj.status == 0) {
			ays = true;
			authen = false;
		}
		else{
		ays = true;
		authen = true;
		}
	});
	request.fail(function(jqXHR, textStatus) {
		//alert("Request failed: " + textStatus);
		ays = true;
		authen = false;
	});
	return authen;
}
